home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / thomas / thomas.lha / Thomas / Thomas-1.1 / src / runtime-collections.scm < prev    next >
Text File  |  1992-09-09  |  4KB  |  95 lines

  1. ;*              Copyright 1992 Digital Equipment Corporation
  2. ;*                         All Rights Reserved
  3. ;*
  4. ;* Permission to use, copy, and modify this software and its documentation is
  5. ;* hereby granted only under the following terms and conditions.  Both the
  6. ;* above copyright notice and this permission notice must appear in all copies
  7. ;* of the software, derivative works or modified versions, and any portions
  8. ;* thereof, and both notices must appear in supporting documentation.
  9. ;*
  10. ;* Users of this software agree to the terms and conditions set forth herein,
  11. ;* and hereby grant back to Digital a non-exclusive, unrestricted, royalty-free
  12. ;* right and license under any changes, enhancements or extensions made to the
  13. ;* core functions of the software, including but not limited to those affording
  14. ;* compatibility with other hardware or software environments, but excluding
  15. ;* applications which incorporate this software.  Users further agree to use
  16. ;* their best efforts to return to Digital any such changes, enhancements or
  17. ;* extensions that they make and inform Digital of noteworthy uses of this
  18. ;* software.  Correspondence should be provided to Digital at:
  19. ;* 
  20. ;*            Director, Cambridge Research Lab
  21. ;*            Digital Equipment Corp
  22. ;*            One Kendall Square, Bldg 700
  23. ;*            Cambridge MA 02139
  24. ;* 
  25. ;* This software may be distributed (but not offered for sale or transferred
  26. ;* for compensation) to third parties, provided such third parties agree to
  27. ;* abide by the terms and conditions of this notice.  
  28. ;* 
  29. ;* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
  30. ;* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
  31. ;* MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
  32. ;* CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  33. ;* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  34. ;* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
  35. ;* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  36. ;* SOFTWARE.
  37.  
  38. ; $Id: runtime-collections.scm,v 1.19 1992/09/09 22:12:55 jmiller Exp $
  39.  
  40. ;;;;; RUNTIME-COLLECTIONS.SCM
  41.  
  42. ;;;;; The specializations of method based on collection type are in the file:
  43. ;;;;; runtime-collections-xxx.scm (where xxx is collection type)
  44.  
  45. ;;; Class definitions on pages 111 and 112 imply specialization for
  46. ;;; the make operation.
  47. ;;;
  48. ;;; General theory of operation: some of the collection types are
  49. ;;; handled very, very specially to make them more efficient.  In
  50. ;;; particular:
  51. ;;;  <byte-string> : implemented as a Scheme string,
  52. ;;;  <simple-object-vector> : implemented as a Scheme vector
  53. ;;;  <list>, <pair>, <empty-list> : implemented in Scheme
  54. ;;; 
  55. ;;; All other collection types are instances (in the sense of
  56. ;;; "created by calling make-instance in class.scm").
  57. ;;;
  58. ;;; Consequences of this decision: any generic operation on a class
  59. ;;; which is a superclass of one of the special classes MUST BE
  60. ;;; SPECIALIZED for the special case.  This can either be done by
  61. ;;; conditionalizing the code that handles the superclass or by
  62. ;;; providing a specific method for the special subclass.
  63.  
  64.  
  65. ;;; KNOWN PROBLEMS
  66.  
  67. ;;;
  68. ;;; UTILITY FUNCTIONS
  69. ;;;
  70. (define (one-arg name type fn)
  71.   (dylan::function->method
  72.    (make-param-list `((,name ,type)) #F #F #F) fn))
  73.  
  74. (define (but-last list)
  75.   (reverse (cdr (reverse list))))
  76.  
  77. (define (create-private-slot owner type-restriction name continue)
  78.   ;; Adds a new slot to an existing class, and returns the getter and
  79.   ;; setter generic functions to be used for the slot.
  80.   (define the-getter
  81.     (dylan::generic-fn (new-name "dylan:" name "-getter")
  82.       (make-param-list `((ARRAY ,<object>)) #F #F #F)
  83.       #F))
  84.  
  85.   (define the-setter
  86.     (dylan::generic-fn (new-name "dylan:" name "-setter!")
  87.       (make-param-list `((ARRAY ,<object>) (VALUE ,<object>)) #F #F #F)
  88.       #F))
  89.  
  90.   (dylan::add-slot owner
  91.            type-restriction 'INSTANCE the-setter the-getter
  92.            (new-name "" name "") #F #F #F #F #F)
  93.  
  94.   (continue the-setter the-getter))
  95.